package com.etc.threaddemo;

/**
 * @author: knowno
 * @create: 2024-09-13 09:16
 * @Version 1.0
 * 2. 线程实现的方式2： 实现Runnable接口，重写run方法
 * 将这个对象作为Thread的参数.
 **/
public class TestThread3 {
    public static void main(String[] args) {


        MyThread3 myThread1 = new MyThread3();

        MyThread3 myThread2 = new MyThread3();
        //如果是runnable的接口的实现类，我们需要将这个对象提供给Thread类作为参数使用

        new Thread(myThread1).start();
        new Thread(myThread2).start();

    }
}

class MyThread3 implements Runnable {
    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            System.out.println(Thread.currentThread().getId() + "," + Thread.currentThread().getName());
        }
    }
}
